<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require_once('appcomponent.php');

class Emailer extends AppComponent
{
	var $ci;
	
    public function __construct()
    {
        parent::__construct();
        // Do something with $params        
        $this->ci =& get_instance();
        $this->ci->load->library('email');
		$this->ci->config->load('email_notification');
	}
    
    public function send_email($from, $to,$subject,$message,$cc="",$bcc="",$attach="")
    {
        $email_from = $this->ci->config->item($from);        

        $this->ci->email->from($email_from, $this->ci->config->item('email_from_name'));
        $this->ci->email->to($to);
        if(!empty($cc))
        {
        $this->ci->email->cc($cc);
        }
        if(!empty($bcc))
        {
        $this->ci->email->bcc($bcc);
        }
        if(!empty($attach))
        {
        $this->ci->email->attach($attach);
        }
        $this->ci->email->subject($subject);
        $this->ci->email->message($message);
        $sent=$this->ci->email->send();
        return $sent;
    }
}
?>